<?php
/**
 * @fileoverview    单品最终页
 * @author          gaojian3
 * @date            2012.02.10
 * @copyright       sina meila
 */

include ('../../__global.php');

class goods_redirect extends ml_controller 
{
    private $url;
    private $t;
    private $rid;
    public function initParam()
    {
        $this->url=$this->input('url','get');
        $this->t=$this->input('t','get');
        $this->rid = $this->input('rid','get');
    }
    
    public function checkParam()
    {
        
    }
    
    public function main()
    {
        if($this->t)
        {
            $oTinyurl = new ml_model_mcTinyurl();
            $long = $oTinyurl->tiny2longurl($this->t);
            
            
            if(substr($long , 0 , 7) != 'http://' && substr($long , 0 , 8) != 'https://')
                $long = 'http://'.$long;
                
            //投放统计数据
            $url_info = parse_url($long);
            parse_str($url_info['query'] , $a);
            if($a['Tfrom'] == 'wb')
            {
                //$long = substr($long , 0 , strpos($long , '?'));
                $tag = $a['Ttag'] ? $a['Ttag'] : $a['tag'];
                $url = 'http://i.api.open.blog.sina.com.cn/blog/v2.0/rank?top_name=mlcomment&top_key='.$tag.'&from=meila&user_ip='.Tool_ip::get_real_ip();
                Tool_http::get($url , 3);
            }
            
            //统计淘宝客链接
            if($url_info['host'] == 's.click.taobao.com' && !ml_tool_ua::is_fake_visitor())
            {
                Tool_logger::dataLog('taobaoke_go' , $a['p'].' '.$this->t , true , true , true);
            }
            
            if($this->rid && ml_tool_resid::is_resid($this->rid))
            {
                $oContent = new ml_model_dbContent();
                $rs = $oContent->get_by_rid($this->rid);
                $aContent = $oContent->get_data();
                ml_tool_actionlog::view_jump_goods($this->__visitor['uid'] , $this->rid , $aContent['gd_catelog'] , $aContent['gd_info']['tags'] , $aContent['gd_price'] , $long);
            }
            
            $url = $long;
            
        }
        else 
        {
            $url = $this->url;
        }
        $this->redirect($url);        
    }
}
new goods_redirect();